/*
 * @Description:帮助
 * @Author: maskMan
 * @LastEditTime: 2024-10-21 09:01:45
 */
import { MARK } from '../general/constants'
import resManager from '../general/resManager'
import { playEffect } from '../general/shorts'
const { ccclass, property } = cc._decorator
@ccclass
export default class Help extends cc.Component {
  @property(cc.Node)
  content_node: cc.Node = null
  @property(cc.Node)
  commit_node: cc.Node = null
  @property(cc.Label)
  descStr: cc.Label = null
  gamePath: IGamePath
  onLoad() {
    try {
      if (this.gamePath) {
        const dir = `games/${this.gamePath.gamePack}/${this.gamePath.gamePack}`
        resManager.loadRes<cc.JsonAsset>(dir, cc.JsonAsset).then((res) => {
          if (res) {
            this.descStr.string = res.json[0]
          }
        })
      }
    } catch (error) {
      console.log('error: ', error)
    }
  }
  start() {
    this._openAction()
  }
  /**打开动画 */
  private _openAction() {
    playEffect('shui')
    const rootNode = this.node
    rootNode.x = 0
    rootNode.y = -812
    rootNode.runAction(cc.moveTo(0.5, 0, 0).easing(cc.easeBackOut()))
  }
  /**关闭动画 */
  onClose() {
    const rootNode = this.node
    playEffect('close')
    rootNode.runAction(
      cc.sequence(
        cc.moveTo(0.4, 0, -750).easing(cc.easeBackIn()),
        cc.callFunc(() => {
          this.node.emit(MARK.NODE_EVENT, true)
          rootNode.destroy()
        })
      )
    )
  }
}
